//
//  TraDetaHeaView.m
//  XhlTrip
//
//  Created by dllo on 15/8/25.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "TraDetaHeaView.h"
#import "TravelModel.h"
#import "UIImageView+WebCache.h"

@implementation TraDetaHeaView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
 
        [self create];
    }
    return self;
}

- (void)create
{
   

    self.MaxImageView = [[UIImageView alloc] init];
    self.MaxImageView.userInteractionEnabled = YES;
    [self addSubview:self.MaxImageView];
    [_MaxImageView release];
    
    
    
    
    self.SmallImageView = [[UIImageView alloc] init];
    [self.MaxImageView addSubview:_SmallImageView];
    [_SmallImageView release];
    _SmallImageView.layer.cornerRadius = 5;
    _SmallImageView.layer.borderWidth = 2.5;
    _SmallImageView.layer.borderColor = [UIColor whiteColor].CGColor;
    
    
    self.nameLabel = [[UILabel alloc] init];
    self.nameLabel.numberOfLines = 0;
    [self.MaxImageView addSubview:_nameLabel];
    
    
    self.datalabel = [[UILabel alloc] init];
    [self.MaxImageView addSubview:_datalabel];
    [_datalabel release];
    
    self.daysLabel = [[UILabel alloc] init];
    [self.MaxImageView addSubview:_daysLabel];
    [_daysLabel release];
    
    self.pCountLabel = [[UILabel alloc] init];
    [self.MaxImageView addSubview:_pCountLabel];
    [_pCountLabel release];
    
    _daysLabel.textColor = [UIColor whiteColor];
    _daysLabel.highlighted = YES;
    _daysLabel.font = [UIFont fontWithName:@"Verdana-BoldItalic" size:14 * Width];
    
    _pCountLabel.textColor = [UIColor whiteColor];
    _pCountLabel.highlighted = YES;
    _pCountLabel.font = [UIFont fontWithName:@"Verdana-BoldItalic" size:14 * Width];
    
    _datalabel.textColor = [UIColor whiteColor];
    _datalabel.highlighted = YES;
    _datalabel.font = [UIFont fontWithName:@"Verdana-BoldItalic" size:14 * Width];
    
    _nameLabel.font = [UIFont fontWithName:@"Verdana-BoldItalic" size:18 * Width];
    _nameLabel.textColor = [UIColor whiteColor];
    _nameLabel.highlighted = YES;
    
    
    self.SmallImageView.frame = CGRectMake(10 * Width, 130 * Height, 40 * Width, 40 * Height);
    self.nameLabel.frame = CGRectMake(60 * Width, 120 * Height, self.MaxImageView.frame.size.width - 70 * Width, 60 * Height);
    
    
    self.datalabel.frame = CGRectMake(60 * Width, 167 * Height, 100 * Width, 25 * Height);
    //self.daysLabel.frame = CGRectMake(110, 60, 50, 25);
    self.pCountLabel.frame = CGRectMake(160 * Width, 167 * Height, 50 * Width, 25 * Height);
}

/* 重写set方法 用model给控件赋值 */
-(void)setTravelModel:(TravelModel *)travelModel
{
    if (_travelModel != travelModel) {
        [_travelModel release];
        _travelModel = [travelModel retain];
    }
    [_MaxImageView sd_setImageWithURL:travelModel.front_cover_photo_url];
    _nameLabel.text = travelModel.name;
    _datalabel.text = travelModel.start_date;
    _daysLabel.text =[NSString stringWithFormat:@"%@%@", [travelModel.days stringValue], @"天"];
    _pCountLabel.text =[ NSString stringWithFormat:@"%@%@", [travelModel.photos_count stringValue], @"图"];
    
}






- (void)dealloc
{
    [_travelModel release];
    [_MaxImageView release];
    [_SmallImageView release];
    [_nameLabel release];
    [_datalabel release];
    [_daysLabel release];
    [_pCountLabel release];
    [_effectview release];
    [_hhhh release];
    [super dealloc];
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
